#!/usr/bin/env python

'''Generate resource

@author Julot <andy.julot@gmail.com>
@since Tuesday, February 14, 2012. 02:23 PM'''

import os

from wx.tools import img2py

def capitalize(value):
    values = value.split('-')
    for index in range(len(values)):
        values[index] = values[index].capitalize()
    return ''.join(values)

def embed(virgin, name, path, pyFile, isIcon=False):
    args = []
    if not virgin: args.append('-a')
    args.append('-F')
    if isIcon: args.append('-i')
    args.append('-n')
    args.append(capitalize(name))
    args.append(path)
    args.append(pyFile)
    img2py.main(args)

resources = {
    'icon': ['main'],
    'image': ['about', 'python', 'wx'],
    'toolbar': ['about', 'door-open-out', 'question-button', 'upload-cloud',
                'folder-open-image']
    }

if __name__ == '__main__':
    for r in resources:
        virgin = True
        isIcon = True if r == 'icon' else False
        ext = 'ico' if isIcon else 'png'
        for e in resources[r]:
            path = os.path.join(r, '%s.%s' % (e, ext))
            embed(virgin, e, path, '%s.py' % r, isIcon)
            virgin = False